<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="js/jquery-3.6.1.min.js" type="text/javascript"></script>
</head>
<body>
<%--  <a href="account/getAccountList">账户列表</a>--%>
<h5><a href="${pageContext.request.contextPath}/account/getAccountList">逻辑视图名</a></h5>

<h5><a href="${pageContext.request.contextPath}/account/getAccountByName?name=张三">ModelAndView</a></h5>

<h5><a href="${pageContext.request.contextPath}/account/getAccountByIdName/1/zhangsan">RESTFUL</a></h5>

<h5><a href="${pageContext.request.contextPath}/account/getAccountByCt?ct=2023-02-15">类型转换</a></h5>

<h5><a href="${pageContext.request.contextPath}/account/testAnno">其它</a></h5>

<form action="account/addAccount" method="post">
    <h3>ID: <input type="text" name="id"></h3>
    <h3>名称: <input type="text" name="name"></h3>
    <h3>余额: <input type="text" name="balance"></h3>
    <button type="submit">保存</button>
</form>
<button id="jn">json</button>
<script type="text/javascript">
    // $('#jn').click(function () {
    //     $.ajax({
    //         url: 'account/addAccountJson',
    //         type: 'get',
    //         dataType: 'json',
    //         data: {
    //             name: 'zhangsan',
    //             balance: 1000
    //         },
    //         contentType: "application/x-www-form-urlencoded; charset=UTF-8",
    //         success: function (data) {
    //             console.log(data);
    //         }
    //     })
    // })
    $('#jn').click(function () {
        $.ajax({
            url: 'account/addAccountJson',
            type: 'post',
            dataType: 'json',
            data: JSON.stringify({"name": "zhangsan", "balance": 1000}),
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                console.log(data);
            }
        })
    })
</script>
</body>
</html>
